import { call, put, takeEvery, takeLatest } from 'redux-saga/effects'

import { INIT_LIST_DATA } from './action-types'
import axios from 'axios'
import qs from 'qs'
function* mySaga (action) {
  try {
    let res = yield axios.post('https://service.hzbanshi.cn/library/search', qs.stringify({
      word: '金',
      currentPage: 1,
      pageSize: 10,
      isClick: 0
    }))
    let result = res.data.data.books.map(obj => obj.title)
    yield put({ type: INIT_LIST_DATA, data: result })
  } catch (error) {
    console.error(error)
  }
}

export default mySaga